package org.gingresosapi.persistencia;

import org.gingresosapi.beans.Vehiculos;
import java.sql.Date; 
import org.gingresosapi.beans.*;
import org.gingresosapi.controller.*;
import java.io.Serializable;
import java.util.List;
import java.util.ArrayList;
import java.util.*;
import java.sql.Connection;
import java.sql.Statement;
import java.sql.ResultSet;
import java.sql.PreparedStatement;
import java.util.Map;
import java.util.Iterator;
import java.util.HashMap;
import java.util.Map;
 import javax.sql.DataSource;
import org.gingresosapi.generales.Mensajeria;
import org.gingresosapi.generales.DataGManager;


/**
*
* @author
*/

public class VehiculosPersistencia implements Serializable {
private static final long serialVersionUID = 1L;
public static Exception excepcion;
public static boolean esMensaje = false;
public static Connection con = null;
public static java.util.ResourceBundle bundle = java.util.ResourceBundle.getBundle("org/gingresosapi/properties/mensajes");
static DataGManager dataGManager;
static List<Vehiculos> list;

public VehiculosPersistencia(){
         esMensaje =false;
}


/**
*
* insert()
*/

public static boolean insert (Vehiculos vehiculos ) {
  excepcion = null;
  try {
      esMensaje =false;
   
   
   

  con= dataGManager.getCon();
  if (con == null) {
      excepcion=new Exception(bundle.getString("msg.noconecction"));
      return false;
  }
      PreparedStatement pinsert = null;
      String sql = "insert into vehiculos(idvehiculo,placa,marca,modelo,anio,chasis,capacidad,valor,motor,color,descripcion,tipo,combustible,uso,id,tipoid,hipotecado,secuestrado,traspaso,activo,idmunicipio,pagoinscripcion,fechainscripcion,fecha,username,liquidacion,fechaliquidacion,mespago,fideicomiso)  values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
      pinsert = con.prepareStatement(sql);
              pinsert.setInt(1,vehiculos.getIdvehiculo());
        pinsert.setString(2,vehiculos.getPlaca());
        pinsert.setString(3,vehiculos.getMarca());
        pinsert.setString(4,vehiculos.getModelo());
        pinsert.setInt(5,vehiculos.getAnio());
        pinsert.setString(6,vehiculos.getChasis());
        pinsert.setString(7,vehiculos.getCapacidad());
        pinsert.setDouble(8,vehiculos.getValor());
        pinsert.setString(9,vehiculos.getMotor());
        pinsert.setString(10,vehiculos.getColor());
        pinsert.setString(11,vehiculos.getDescripcion());
        pinsert.setString(12,vehiculos.getTipo());
        pinsert.setString(13,vehiculos.getCombustible());
        pinsert.setString(14,vehiculos.getUso());
        pinsert.setString(15,vehiculos.getId());
        pinsert.setString(16,vehiculos.getTipoid());
        pinsert.setString(17,vehiculos.getHipotecado());
        pinsert.setString(18,vehiculos.getSecuestrado());
        pinsert.setString(19,vehiculos.getTraspaso());
        pinsert.setString(20,vehiculos.getActivo());
        pinsert.setString(21,vehiculos.getIdmunicipio());
        pinsert.setString(22,vehiculos.getPagoinscripcion());
        pinsert.setDate(23,vehiculos.getFechainscripcion());
        pinsert.setDate(24,vehiculos.getFecha());
        pinsert.setString(25,vehiculos.getUsername());
        pinsert.setString(26,vehiculos.getLiquidacion());
        pinsert.setDate(27,vehiculos.getFechaliquidacion());
        pinsert.setString(28,vehiculos.getMespago());
        pinsert.setString(29,vehiculos.getFideicomiso());
      int filas= pinsert.executeUpdate();
      pinsert.close();
      return true;
   } catch (Exception e) {
      excepcion = e;
   } finally {
  }
  return false;
 }


/**
*
* update()
*/

public static boolean update(Vehiculos vehiculos ) {
  excepcion = null;
  try {
      esMensaje =false;

  con= dataGManager.getCon();
  if (con == null) {
      excepcion=new Exception(bundle.getString("msg.noconecction"));
      return false;
  }
      PreparedStatement pupdate = null;
      String sql = "update vehiculos set  idvehiculo=?, placa=?, marca=?, modelo=?, anio=?, chasis=?, capacidad=?, valor=?, motor=?, color=?, descripcion=?, tipo=?, combustible=?, uso=?, id=?, tipoid=?, hipotecado=?, secuestrado=?, traspaso=?, activo=?, idmunicipio=?, pagoinscripcion=?, fechainscripcion=?, fecha=?, username=?, liquidacion=?, fechaliquidacion=?, mespago=?, fideicomiso=?  where  idvehiculo ='"+vehiculos.getIdvehiculo()+"' and  idmunicipio ='"+vehiculos.getIdmunicipio()+"'  ";
      pupdate= con.prepareStatement(sql);
      pupdate.setInt(1,vehiculos.getIdvehiculo());
pupdate.setString(2,vehiculos.getPlaca());
pupdate.setString(3,vehiculos.getMarca());
pupdate.setString(4,vehiculos.getModelo());
pupdate.setInt(5,vehiculos.getAnio());
pupdate.setString(6,vehiculos.getChasis());
pupdate.setString(7,vehiculos.getCapacidad());
pupdate.setDouble(8,vehiculos.getValor());
pupdate.setString(9,vehiculos.getMotor());
pupdate.setString(10,vehiculos.getColor());
pupdate.setString(11,vehiculos.getDescripcion());
pupdate.setString(12,vehiculos.getTipo());
pupdate.setString(13,vehiculos.getCombustible());
pupdate.setString(14,vehiculos.getUso());
pupdate.setString(15,vehiculos.getId());
pupdate.setString(16,vehiculos.getTipoid());
pupdate.setString(17,vehiculos.getHipotecado());
pupdate.setString(18,vehiculos.getSecuestrado());
pupdate.setString(19,vehiculos.getTraspaso());
pupdate.setString(20,vehiculos.getActivo());
pupdate.setString(21,vehiculos.getIdmunicipio());
pupdate.setString(22,vehiculos.getPagoinscripcion());
pupdate.setDate(23,vehiculos.getFechainscripcion());
pupdate.setDate(24,vehiculos.getFecha());
pupdate.setString(25,vehiculos.getUsername());
pupdate.setString(26,vehiculos.getLiquidacion());
pupdate.setDate(27,vehiculos.getFechaliquidacion());
pupdate.setString(28,vehiculos.getMespago());
pupdate.setString(29,vehiculos.getFideicomiso());
      int filas= pupdate.executeUpdate();
      pupdate.close();
      if (filas <= 0){
          excepcion=new Exception(bundle.getString("msg.noupdate"));
          esMensaje =true;
          return false;
      }
      return true;
   } catch (Exception e) {
      excepcion = e;
   } finally {
  }
  return false;
}


/**
*
* update()
*/

public static boolean update(String sqlupdate ) {
  excepcion = null;
  try {
      esMensaje =false;

  con= dataGManager.getCon();
  if (con == null) {
      excepcion=new Exception(bundle.getString("msg.noconecction"));
      return false;
  }
      PreparedStatement pupdate = null;
      String sql = "update  vehiculos set " + sqlupdate +"";
      pupdate= con.prepareStatement(sql);
      int filas= pupdate.executeUpdate();
      pupdate.close();
      if (filas <= 0){
          excepcion=new Exception(bundle.getString("msg.noupdate"));
          esMensaje =true;
          return false;
      }
      return true;
   } catch (Exception e) {
      excepcion = e;
   } finally {
  }
  return false;
}


/**
*
* updatePrimaryKey()
*/

public static boolean updatePrimaryKey(Vehiculos vehiculos_old , Vehiculos vehiculos) {
  excepcion = null;
  try {
      esMensaje =false;

  con= dataGManager.getCon();
  if (con == null) {
      excepcion=new Exception(bundle.getString("msg.noconecction"));
      return false;
  }
      PreparedStatement pupdate = null;
      String sql = "update vehiculos set  idvehiculo=? ,  idmunicipio=?  where  idvehiculo ='"+vehiculos_old.getIdvehiculo()+"' and  idmunicipio ='"+vehiculos_old.getIdmunicipio()+"'  ";
      pupdate= con.prepareStatement(sql);
      pupdate.setInt(1,vehiculos.getIdvehiculo());pupdate.setString(21,vehiculos.getIdmunicipio());
      int filas= pupdate.executeUpdate();
      pupdate.close();
      if (filas <= 0){
          excepcion=new Exception(bundle.getString("msg.noupdate"));
          esMensaje =true;
          return false;
      }
      return true;
   } catch (Exception e) {
      excepcion = e;
   } finally {
  }
  return false;
}


/**
*
* delete()
*/

public static boolean delete(Vehiculos vehiculos ) {
  excepcion = null;
  try {
      esMensaje =false;

  con= dataGManager.getCon();
  if (con == null) {
      excepcion=new Exception(bundle.getString("msg.noconecction"));
      return false;
  }
      PreparedStatement pdelete = null;
      String sql = "delete from vehiculos  where  idvehiculo = ? and  idmunicipio = ?  ";
      pdelete= con.prepareStatement(sql);
      pdelete.setInt(1,vehiculos.getIdvehiculo());
pdelete.setString(21,vehiculos.getIdmunicipio());
      int filas= pdelete.executeUpdate();
      pdelete.close();
      if (filas <= 0){
          excepcion=new Exception(bundle.getString("msg.nodelete"));
          esMensaje =true;
          return false;
      }
      return true;
   } catch (Exception e) {
      excepcion = e;
   } finally {
  }
  return false;
}


/**
*
* delete()
*/

public static boolean delete(String sqldelete ) {
  excepcion = null;
  try {
      esMensaje =false;

  con= dataGManager.getCon();
  if (con == null) {
      excepcion=new Exception(bundle.getString("msg.noconecction"));
      return false;
  }
      PreparedStatement pdelete = null;
      String sql = "delete from vehiculos where " + sqldelete +"";
      pdelete= con.prepareStatement(sql);
      int filas= pdelete.executeUpdate();
      pdelete.close();
      if (filas <= 0){
          excepcion=new Exception(bundle.getString("msg.nodelete"));
          esMensaje =true;
          return false;
      }
      return true;
   } catch (Exception e) {
      excepcion = e;
   } finally {
  }
  return false;
}


/**
*
* deleteAll()
*/

public static boolean deleteAll() {
  excepcion = null;
  try {
      esMensaje =false;

  con= dataGManager.getCon();
  if (con == null) {
      excepcion=new Exception(bundle.getString("msg.noconecction"));
      return false;
  }
      PreparedStatement pdelete = null;
      String sql = "delete from vehiculos  ";
      pdelete= con.prepareStatement(sql);
      int filas= pdelete.executeUpdate();
      pdelete.close();
      if (filas <= 0){
          excepcion=new Exception(bundle.getString("msg.nodeleteall"));
          esMensaje =true;
          return false;
      }
      return true;
   } catch (Exception e) {
      excepcion = e;
   } finally {
  }
  return false;
}


/**
*
* exists()
*/



public static boolean exists(Vehiculos vehiculos) {
  excepcion = null;
  try {
      esMensaje =false;

  con= dataGManager.getCon();
  if (con == null) {
      excepcion=new Exception(bundle.getString("msg.noconecction"));
      return false;
  }
      String sql = "select * from vehiculos where idvehiculo='"+vehiculos.getIdvehiculo()+"' and idmunicipio='"+vehiculos.getIdmunicipio()+"'";
  PreparedStatement psquery = con.prepareStatement(sql,ResultSet.TYPE_SCROLL_INSENSITIVE,
                                      ResultSet.CONCUR_UPDATABLE);
   ResultSet rs = psquery.executeQuery();
   rs.next();
   int x = rs.getRow();
   if (x == 0) {
          excepcion=new Exception(bundle.getString("msg.nofoundrecords") + "vehiculos" +" " + bundle.getString("msg.withcode"));
          esMensaje =true;
      rs.close();
      psquery.close();
      return false;
   }
    rs.close();
    psquery.close();
 return true;
} catch (Exception ex) {
      excepcion = ex;
}
  return false;
}


/**
*
* findByPrimaryKey()
*/



public static Vehiculos findByPrimaryKey(Vehiculos vehiculos) {
  excepcion = null;
  try {
      esMensaje =false;

  con= dataGManager.getCon();
  if (con == null) {
      excepcion=new Exception(bundle.getString("msg.noconecction"));
      return null;
  }
      String sql = "select * from vehiculos where idvehiculo='"+vehiculos.getIdvehiculo()+"' and idmunicipio='"+vehiculos.getIdmunicipio()+"'";
  PreparedStatement psquery = con.prepareStatement(sql,ResultSet.TYPE_SCROLL_INSENSITIVE,
                                      ResultSet.CONCUR_UPDATABLE);
   ResultSet rs = psquery.executeQuery();
   rs.next();
   int x = rs.getRow();
   if (x == 0) {
          excepcion=new Exception(bundle.getString("msg.nofoundrecords") + "vehiculos" +"  "+ bundle.getString("msg.withcode"));
          esMensaje =true;
      rs.close();
      psquery.close();
      return null;
   }
   rs.beforeFirst();
   while (rs.next()) {
   
            
            
            vehiculos.setIdvehiculo(rs.getInt("idvehiculo"));
vehiculos.setPlaca(rs.getString("placa"));
vehiculos.setMarca(rs.getString("marca"));
vehiculos.setModelo(rs.getString("modelo"));
vehiculos.setAnio(rs.getInt("anio"));
vehiculos.setChasis(rs.getString("chasis"));
vehiculos.setCapacidad(rs.getString("capacidad"));
vehiculos.setValor(rs.getDouble("valor"));
vehiculos.setMotor(rs.getString("motor"));
vehiculos.setColor(rs.getString("color"));
vehiculos.setDescripcion(rs.getString("descripcion"));
vehiculos.setTipo(rs.getString("tipo"));
vehiculos.setCombustible(rs.getString("combustible"));
vehiculos.setUso(rs.getString("uso"));
vehiculos.setId(rs.getString("id"));
vehiculos.setTipoid(rs.getString("tipoid"));
vehiculos.setHipotecado(rs.getString("hipotecado"));
vehiculos.setSecuestrado(rs.getString("secuestrado"));
vehiculos.setTraspaso(rs.getString("traspaso"));
vehiculos.setActivo(rs.getString("activo"));
vehiculos.setIdmunicipio(rs.getString("idmunicipio"));
vehiculos.setPagoinscripcion(rs.getString("pagoinscripcion"));
vehiculos.setFechainscripcion(rs.getDate("fechainscripcion"));
vehiculos.setFecha(rs.getDate("fecha"));
vehiculos.setUsername(rs.getString("username"));
vehiculos.setLiquidacion(rs.getString("liquidacion"));
vehiculos.setFechaliquidacion(rs.getDate("fechaliquidacion"));
vehiculos.setMespago(rs.getString("mespago"));
vehiculos.setFideicomiso(rs.getString("fideicomiso"));
    }
    rs.close();
    psquery.close();
 return vehiculos;
} catch (Exception ex) {
      excepcion = ex;
}
  return null;
}


/**
*
* findByIdvehiculo()
*/

public static List<Vehiculos> findByIdvehiculo(Vehiculos vehiculos,boolean withRelation) {
  excepcion = null;
  try {
      esMensaje =false;

  con= dataGManager.getCon();
  if (con == null) {
      excepcion=new Exception(bundle.getString("msg.noconecction"));
      return null;
  }
       list = new ArrayList<Vehiculos>();
      String sql = "select * from vehiculos where idvehiculo='"+vehiculos.getIdvehiculo()+"'";
  PreparedStatement psquery = con.prepareStatement(sql,ResultSet.TYPE_SCROLL_INSENSITIVE,
                                      ResultSet.CONCUR_UPDATABLE);
   ResultSet rs = psquery.executeQuery();
   rs.next();
   int x = rs.getRow();
   if (x == 0) {
          excepcion=new Exception(bundle.getString("msg.nofoundrecords") + "vehiculos" +"  "+ bundle.getString("msg.withcode"));
          esMensaje =true;
      rs.close();
      psquery.close();
      return null;
   }
   rs.beforeFirst();
   while (rs.next()) {
   
        Vehiculos vehiculos2 = new Vehiculos(
         rs.getInt("idvehiculo"),rs.getString("placa"),rs.getString("marca"),rs.getString("modelo"),rs.getInt("anio"),rs.getString("chasis"),rs.getString("capacidad"),rs.getDouble("valor"),rs.getString("motor"),rs.getString("color"),rs.getString("descripcion"),rs.getString("tipo"),rs.getString("combustible"),rs.getString("uso"),rs.getString("id"),rs.getString("tipoid"),rs.getString("hipotecado"),rs.getString("secuestrado"),rs.getString("traspaso"),rs.getString("activo"),rs.getString("idmunicipio"),rs.getString("pagoinscripcion"),rs.getDate("fechainscripcion"),rs.getDate("fecha"),rs.getString("username"),rs.getString("liquidacion"),rs.getDate("fechaliquidacion"),rs.getString("mespago"),rs.getString("fideicomiso"));
            
            
       list.add(vehiculos2);
    }
    rs.close();
    psquery.close();
    return list;
} catch (Exception ex) {
      excepcion = ex;
}
  return null;
}


/**
*
* findByPlaca()
*/

public static List<Vehiculos> findByPlaca(Vehiculos vehiculos,boolean withRelation) {
  excepcion = null;
  try {
      esMensaje =false;

  con= dataGManager.getCon();
  if (con == null) {
      excepcion=new Exception(bundle.getString("msg.noconecction"));
      return null;
  }
       list = new ArrayList<Vehiculos>();
      String sql = "select * from vehiculos where placa='"+vehiculos.getPlaca()+"'";
  PreparedStatement psquery = con.prepareStatement(sql,ResultSet.TYPE_SCROLL_INSENSITIVE,
                                      ResultSet.CONCUR_UPDATABLE);
   ResultSet rs = psquery.executeQuery();
   rs.next();
   int x = rs.getRow();
   if (x == 0) {
          excepcion=new Exception(bundle.getString("msg.nofoundrecords") + "vehiculos" +"  "+ bundle.getString("msg.withcode"));
          esMensaje =true;
      rs.close();
      psquery.close();
      return null;
   }
   rs.beforeFirst();
   while (rs.next()) {
   
        Vehiculos vehiculos2 = new Vehiculos(
         rs.getInt("idvehiculo"),rs.getString("placa"),rs.getString("marca"),rs.getString("modelo"),rs.getInt("anio"),rs.getString("chasis"),rs.getString("capacidad"),rs.getDouble("valor"),rs.getString("motor"),rs.getString("color"),rs.getString("descripcion"),rs.getString("tipo"),rs.getString("combustible"),rs.getString("uso"),rs.getString("id"),rs.getString("tipoid"),rs.getString("hipotecado"),rs.getString("secuestrado"),rs.getString("traspaso"),rs.getString("activo"),rs.getString("idmunicipio"),rs.getString("pagoinscripcion"),rs.getDate("fechainscripcion"),rs.getDate("fecha"),rs.getString("username"),rs.getString("liquidacion"),rs.getDate("fechaliquidacion"),rs.getString("mespago"),rs.getString("fideicomiso"));
            
            
       list.add(vehiculos2);
    }
    rs.close();
    psquery.close();
    return list;
} catch (Exception ex) {
      excepcion = ex;
}
  return null;
}


/**
*
* findByMarca()
*/

public static List<Vehiculos> findByMarca(Vehiculos vehiculos,boolean withRelation) {
  excepcion = null;
  try {
      esMensaje =false;

  con= dataGManager.getCon();
  if (con == null) {
      excepcion=new Exception(bundle.getString("msg.noconecction"));
      return null;
  }
       list = new ArrayList<Vehiculos>();
      String sql = "select * from vehiculos where marca='"+vehiculos.getMarca()+"'";
  PreparedStatement psquery = con.prepareStatement(sql,ResultSet.TYPE_SCROLL_INSENSITIVE,
                                      ResultSet.CONCUR_UPDATABLE);
   ResultSet rs = psquery.executeQuery();
   rs.next();
   int x = rs.getRow();
   if (x == 0) {
          excepcion=new Exception(bundle.getString("msg.nofoundrecords") + "vehiculos" +"  "+ bundle.getString("msg.withcode"));
          esMensaje =true;
      rs.close();
      psquery.close();
      return null;
   }
   rs.beforeFirst();
   while (rs.next()) {
   
        Vehiculos vehiculos2 = new Vehiculos(
         rs.getInt("idvehiculo"),rs.getString("placa"),rs.getString("marca"),rs.getString("modelo"),rs.getInt("anio"),rs.getString("chasis"),rs.getString("capacidad"),rs.getDouble("valor"),rs.getString("motor"),rs.getString("color"),rs.getString("descripcion"),rs.getString("tipo"),rs.getString("combustible"),rs.getString("uso"),rs.getString("id"),rs.getString("tipoid"),rs.getString("hipotecado"),rs.getString("secuestrado"),rs.getString("traspaso"),rs.getString("activo"),rs.getString("idmunicipio"),rs.getString("pagoinscripcion"),rs.getDate("fechainscripcion"),rs.getDate("fecha"),rs.getString("username"),rs.getString("liquidacion"),rs.getDate("fechaliquidacion"),rs.getString("mespago"),rs.getString("fideicomiso"));
            
            
       list.add(vehiculos2);
    }
    rs.close();
    psquery.close();
    return list;
} catch (Exception ex) {
      excepcion = ex;
}
  return null;
}


/**
*
* findByModelo()
*/

public static List<Vehiculos> findByModelo(Vehiculos vehiculos,boolean withRelation) {
  excepcion = null;
  try {
      esMensaje =false;

  con= dataGManager.getCon();
  if (con == null) {
      excepcion=new Exception(bundle.getString("msg.noconecction"));
      return null;
  }
       list = new ArrayList<Vehiculos>();
      String sql = "select * from vehiculos where modelo='"+vehiculos.getModelo()+"'";
  PreparedStatement psquery = con.prepareStatement(sql,ResultSet.TYPE_SCROLL_INSENSITIVE,
                                      ResultSet.CONCUR_UPDATABLE);
   ResultSet rs = psquery.executeQuery();
   rs.next();
   int x = rs.getRow();
   if (x == 0) {
          excepcion=new Exception(bundle.getString("msg.nofoundrecords") + "vehiculos" +"  "+ bundle.getString("msg.withcode"));
          esMensaje =true;
      rs.close();
      psquery.close();
      return null;
   }
   rs.beforeFirst();
   while (rs.next()) {
   
        Vehiculos vehiculos2 = new Vehiculos(
         rs.getInt("idvehiculo"),rs.getString("placa"),rs.getString("marca"),rs.getString("modelo"),rs.getInt("anio"),rs.getString("chasis"),rs.getString("capacidad"),rs.getDouble("valor"),rs.getString("motor"),rs.getString("color"),rs.getString("descripcion"),rs.getString("tipo"),rs.getString("combustible"),rs.getString("uso"),rs.getString("id"),rs.getString("tipoid"),rs.getString("hipotecado"),rs.getString("secuestrado"),rs.getString("traspaso"),rs.getString("activo"),rs.getString("idmunicipio"),rs.getString("pagoinscripcion"),rs.getDate("fechainscripcion"),rs.getDate("fecha"),rs.getString("username"),rs.getString("liquidacion"),rs.getDate("fechaliquidacion"),rs.getString("mespago"),rs.getString("fideicomiso"));
            
            
       list.add(vehiculos2);
    }
    rs.close();
    psquery.close();
    return list;
} catch (Exception ex) {
      excepcion = ex;
}
  return null;
}


/**
*
* findByAnio()
*/

public static List<Vehiculos> findByAnio(Vehiculos vehiculos,boolean withRelation) {
  excepcion = null;
  try {
      esMensaje =false;

  con= dataGManager.getCon();
  if (con == null) {
      excepcion=new Exception(bundle.getString("msg.noconecction"));
      return null;
  }
       list = new ArrayList<Vehiculos>();
      String sql = "select * from vehiculos where anio='"+vehiculos.getAnio()+"'";
  PreparedStatement psquery = con.prepareStatement(sql,ResultSet.TYPE_SCROLL_INSENSITIVE,
                                      ResultSet.CONCUR_UPDATABLE);
   ResultSet rs = psquery.executeQuery();
   rs.next();
   int x = rs.getRow();
   if (x == 0) {
          excepcion=new Exception(bundle.getString("msg.nofoundrecords") + "vehiculos" +"  "+ bundle.getString("msg.withcode"));
          esMensaje =true;
      rs.close();
      psquery.close();
      return null;
   }
   rs.beforeFirst();
   while (rs.next()) {
   
        Vehiculos vehiculos2 = new Vehiculos(
         rs.getInt("idvehiculo"),rs.getString("placa"),rs.getString("marca"),rs.getString("modelo"),rs.getInt("anio"),rs.getString("chasis"),rs.getString("capacidad"),rs.getDouble("valor"),rs.getString("motor"),rs.getString("color"),rs.getString("descripcion"),rs.getString("tipo"),rs.getString("combustible"),rs.getString("uso"),rs.getString("id"),rs.getString("tipoid"),rs.getString("hipotecado"),rs.getString("secuestrado"),rs.getString("traspaso"),rs.getString("activo"),rs.getString("idmunicipio"),rs.getString("pagoinscripcion"),rs.getDate("fechainscripcion"),rs.getDate("fecha"),rs.getString("username"),rs.getString("liquidacion"),rs.getDate("fechaliquidacion"),rs.getString("mespago"),rs.getString("fideicomiso"));
            
            
       list.add(vehiculos2);
    }
    rs.close();
    psquery.close();
    return list;
} catch (Exception ex) {
      excepcion = ex;
}
  return null;
}


/**
*
* findByChasis()
*/

public static List<Vehiculos> findByChasis(Vehiculos vehiculos,boolean withRelation) {
  excepcion = null;
  try {
      esMensaje =false;

  con= dataGManager.getCon();
  if (con == null) {
      excepcion=new Exception(bundle.getString("msg.noconecction"));
      return null;
  }
       list = new ArrayList<Vehiculos>();
      String sql = "select * from vehiculos where chasis='"+vehiculos.getChasis()+"'";
  PreparedStatement psquery = con.prepareStatement(sql,ResultSet.TYPE_SCROLL_INSENSITIVE,
                                      ResultSet.CONCUR_UPDATABLE);
   ResultSet rs = psquery.executeQuery();
   rs.next();
   int x = rs.getRow();
   if (x == 0) {
          excepcion=new Exception(bundle.getString("msg.nofoundrecords") + "vehiculos" +"  "+ bundle.getString("msg.withcode"));
          esMensaje =true;
      rs.close();
      psquery.close();
      return null;
   }
   rs.beforeFirst();
   while (rs.next()) {
   
        Vehiculos vehiculos2 = new Vehiculos(
         rs.getInt("idvehiculo"),rs.getString("placa"),rs.getString("marca"),rs.getString("modelo"),rs.getInt("anio"),rs.getString("chasis"),rs.getString("capacidad"),rs.getDouble("valor"),rs.getString("motor"),rs.getString("color"),rs.getString("descripcion"),rs.getString("tipo"),rs.getString("combustible"),rs.getString("uso"),rs.getString("id"),rs.getString("tipoid"),rs.getString("hipotecado"),rs.getString("secuestrado"),rs.getString("traspaso"),rs.getString("activo"),rs.getString("idmunicipio"),rs.getString("pagoinscripcion"),rs.getDate("fechainscripcion"),rs.getDate("fecha"),rs.getString("username"),rs.getString("liquidacion"),rs.getDate("fechaliquidacion"),rs.getString("mespago"),rs.getString("fideicomiso"));
            
            
       list.add(vehiculos2);
    }
    rs.close();
    psquery.close();
    return list;
} catch (Exception ex) {
      excepcion = ex;
}
  return null;
}


/**
*
* findByCapacidad()
*/

public static List<Vehiculos> findByCapacidad(Vehiculos vehiculos,boolean withRelation) {
  excepcion = null;
  try {
      esMensaje =false;

  con= dataGManager.getCon();
  if (con == null) {
      excepcion=new Exception(bundle.getString("msg.noconecction"));
      return null;
  }
       list = new ArrayList<Vehiculos>();
      String sql = "select * from vehiculos where capacidad='"+vehiculos.getCapacidad()+"'";
  PreparedStatement psquery = con.prepareStatement(sql,ResultSet.TYPE_SCROLL_INSENSITIVE,
                                      ResultSet.CONCUR_UPDATABLE);
   ResultSet rs = psquery.executeQuery();
   rs.next();
   int x = rs.getRow();
   if (x == 0) {
          excepcion=new Exception(bundle.getString("msg.nofoundrecords") + "vehiculos" +"  "+ bundle.getString("msg.withcode"));
          esMensaje =true;
      rs.close();
      psquery.close();
      return null;
   }
   rs.beforeFirst();
   while (rs.next()) {
   
        Vehiculos vehiculos2 = new Vehiculos(
         rs.getInt("idvehiculo"),rs.getString("placa"),rs.getString("marca"),rs.getString("modelo"),rs.getInt("anio"),rs.getString("chasis"),rs.getString("capacidad"),rs.getDouble("valor"),rs.getString("motor"),rs.getString("color"),rs.getString("descripcion"),rs.getString("tipo"),rs.getString("combustible"),rs.getString("uso"),rs.getString("id"),rs.getString("tipoid"),rs.getString("hipotecado"),rs.getString("secuestrado"),rs.getString("traspaso"),rs.getString("activo"),rs.getString("idmunicipio"),rs.getString("pagoinscripcion"),rs.getDate("fechainscripcion"),rs.getDate("fecha"),rs.getString("username"),rs.getString("liquidacion"),rs.getDate("fechaliquidacion"),rs.getString("mespago"),rs.getString("fideicomiso"));
            
            
       list.add(vehiculos2);
    }
    rs.close();
    psquery.close();
    return list;
} catch (Exception ex) {
      excepcion = ex;
}
  return null;
}


/**
*
* findByValor()
*/

public static List<Vehiculos> findByValor(Vehiculos vehiculos,boolean withRelation) {
  excepcion = null;
  try {
      esMensaje =false;

  con= dataGManager.getCon();
  if (con == null) {
      excepcion=new Exception(bundle.getString("msg.noconecction"));
      return null;
  }
       list = new ArrayList<Vehiculos>();
      String sql = "select * from vehiculos where valor='"+vehiculos.getValor()+"'";
  PreparedStatement psquery = con.prepareStatement(sql,ResultSet.TYPE_SCROLL_INSENSITIVE,
                                      ResultSet.CONCUR_UPDATABLE);
   ResultSet rs = psquery.executeQuery();
   rs.next();
   int x = rs.getRow();
   if (x == 0) {
          excepcion=new Exception(bundle.getString("msg.nofoundrecords") + "vehiculos" +"  "+ bundle.getString("msg.withcode"));
          esMensaje =true;
      rs.close();
      psquery.close();
      return null;
   }
   rs.beforeFirst();
   while (rs.next()) {
   
        Vehiculos vehiculos2 = new Vehiculos(
         rs.getInt("idvehiculo"),rs.getString("placa"),rs.getString("marca"),rs.getString("modelo"),rs.getInt("anio"),rs.getString("chasis"),rs.getString("capacidad"),rs.getDouble("valor"),rs.getString("motor"),rs.getString("color"),rs.getString("descripcion"),rs.getString("tipo"),rs.getString("combustible"),rs.getString("uso"),rs.getString("id"),rs.getString("tipoid"),rs.getString("hipotecado"),rs.getString("secuestrado"),rs.getString("traspaso"),rs.getString("activo"),rs.getString("idmunicipio"),rs.getString("pagoinscripcion"),rs.getDate("fechainscripcion"),rs.getDate("fecha"),rs.getString("username"),rs.getString("liquidacion"),rs.getDate("fechaliquidacion"),rs.getString("mespago"),rs.getString("fideicomiso"));
            
            
       list.add(vehiculos2);
    }
    rs.close();
    psquery.close();
    return list;
} catch (Exception ex) {
      excepcion = ex;
}
  return null;
}


/**
*
* findByMotor()
*/

public static List<Vehiculos> findByMotor(Vehiculos vehiculos,boolean withRelation) {
  excepcion = null;
  try {
      esMensaje =false;

  con= dataGManager.getCon();
  if (con == null) {
      excepcion=new Exception(bundle.getString("msg.noconecction"));
      return null;
  }
       list = new ArrayList<Vehiculos>();
      String sql = "select * from vehiculos where motor='"+vehiculos.getMotor()+"'";
  PreparedStatement psquery = con.prepareStatement(sql,ResultSet.TYPE_SCROLL_INSENSITIVE,
                                      ResultSet.CONCUR_UPDATABLE);
   ResultSet rs = psquery.executeQuery();
   rs.next();
   int x = rs.getRow();
   if (x == 0) {
          excepcion=new Exception(bundle.getString("msg.nofoundrecords") + "vehiculos" +"  "+ bundle.getString("msg.withcode"));
          esMensaje =true;
      rs.close();
      psquery.close();
      return null;
   }
   rs.beforeFirst();
   while (rs.next()) {
   
        Vehiculos vehiculos2 = new Vehiculos(
         rs.getInt("idvehiculo"),rs.getString("placa"),rs.getString("marca"),rs.getString("modelo"),rs.getInt("anio"),rs.getString("chasis"),rs.getString("capacidad"),rs.getDouble("valor"),rs.getString("motor"),rs.getString("color"),rs.getString("descripcion"),rs.getString("tipo"),rs.getString("combustible"),rs.getString("uso"),rs.getString("id"),rs.getString("tipoid"),rs.getString("hipotecado"),rs.getString("secuestrado"),rs.getString("traspaso"),rs.getString("activo"),rs.getString("idmunicipio"),rs.getString("pagoinscripcion"),rs.getDate("fechainscripcion"),rs.getDate("fecha"),rs.getString("username"),rs.getString("liquidacion"),rs.getDate("fechaliquidacion"),rs.getString("mespago"),rs.getString("fideicomiso"));
            
            
       list.add(vehiculos2);
    }
    rs.close();
    psquery.close();
    return list;
} catch (Exception ex) {
      excepcion = ex;
}
  return null;
}


/**
*
* findByColor()
*/

public static List<Vehiculos> findByColor(Vehiculos vehiculos,boolean withRelation) {
  excepcion = null;
  try {
      esMensaje =false;

  con= dataGManager.getCon();
  if (con == null) {
      excepcion=new Exception(bundle.getString("msg.noconecction"));
      return null;
  }
       list = new ArrayList<Vehiculos>();
      String sql = "select * from vehiculos where color='"+vehiculos.getColor()+"'";
  PreparedStatement psquery = con.prepareStatement(sql,ResultSet.TYPE_SCROLL_INSENSITIVE,
                                      ResultSet.CONCUR_UPDATABLE);
   ResultSet rs = psquery.executeQuery();
   rs.next();
   int x = rs.getRow();
   if (x == 0) {
          excepcion=new Exception(bundle.getString("msg.nofoundrecords") + "vehiculos" +"  "+ bundle.getString("msg.withcode"));
          esMensaje =true;
      rs.close();
      psquery.close();
      return null;
   }
   rs.beforeFirst();
   while (rs.next()) {
   
        Vehiculos vehiculos2 = new Vehiculos(
         rs.getInt("idvehiculo"),rs.getString("placa"),rs.getString("marca"),rs.getString("modelo"),rs.getInt("anio"),rs.getString("chasis"),rs.getString("capacidad"),rs.getDouble("valor"),rs.getString("motor"),rs.getString("color"),rs.getString("descripcion"),rs.getString("tipo"),rs.getString("combustible"),rs.getString("uso"),rs.getString("id"),rs.getString("tipoid"),rs.getString("hipotecado"),rs.getString("secuestrado"),rs.getString("traspaso"),rs.getString("activo"),rs.getString("idmunicipio"),rs.getString("pagoinscripcion"),rs.getDate("fechainscripcion"),rs.getDate("fecha"),rs.getString("username"),rs.getString("liquidacion"),rs.getDate("fechaliquidacion"),rs.getString("mespago"),rs.getString("fideicomiso"));
            
            
       list.add(vehiculos2);
    }
    rs.close();
    psquery.close();
    return list;
} catch (Exception ex) {
      excepcion = ex;
}
  return null;
}


/**
*
* findByDescripcion()
*/

public static List<Vehiculos> findByDescripcion(Vehiculos vehiculos,boolean withRelation) {
  excepcion = null;
  try {
      esMensaje =false;

  con= dataGManager.getCon();
  if (con == null) {
      excepcion=new Exception(bundle.getString("msg.noconecction"));
      return null;
  }
       list = new ArrayList<Vehiculos>();
      String sql = "select * from vehiculos where descripcion='"+vehiculos.getDescripcion()+"'";
  PreparedStatement psquery = con.prepareStatement(sql,ResultSet.TYPE_SCROLL_INSENSITIVE,
                                      ResultSet.CONCUR_UPDATABLE);
   ResultSet rs = psquery.executeQuery();
   rs.next();
   int x = rs.getRow();
   if (x == 0) {
          excepcion=new Exception(bundle.getString("msg.nofoundrecords") + "vehiculos" +"  "+ bundle.getString("msg.withcode"));
          esMensaje =true;
      rs.close();
      psquery.close();
      return null;
   }
   rs.beforeFirst();
   while (rs.next()) {
   
        Vehiculos vehiculos2 = new Vehiculos(
         rs.getInt("idvehiculo"),rs.getString("placa"),rs.getString("marca"),rs.getString("modelo"),rs.getInt("anio"),rs.getString("chasis"),rs.getString("capacidad"),rs.getDouble("valor"),rs.getString("motor"),rs.getString("color"),rs.getString("descripcion"),rs.getString("tipo"),rs.getString("combustible"),rs.getString("uso"),rs.getString("id"),rs.getString("tipoid"),rs.getString("hipotecado"),rs.getString("secuestrado"),rs.getString("traspaso"),rs.getString("activo"),rs.getString("idmunicipio"),rs.getString("pagoinscripcion"),rs.getDate("fechainscripcion"),rs.getDate("fecha"),rs.getString("username"),rs.getString("liquidacion"),rs.getDate("fechaliquidacion"),rs.getString("mespago"),rs.getString("fideicomiso"));
            
            
       list.add(vehiculos2);
    }
    rs.close();
    psquery.close();
    return list;
} catch (Exception ex) {
      excepcion = ex;
}
  return null;
}


/**
*
* findByTipo()
*/

public static List<Vehiculos> findByTipo(Vehiculos vehiculos,boolean withRelation) {
  excepcion = null;
  try {
      esMensaje =false;

  con= dataGManager.getCon();
  if (con == null) {
      excepcion=new Exception(bundle.getString("msg.noconecction"));
      return null;
  }
       list = new ArrayList<Vehiculos>();
      String sql = "select * from vehiculos where tipo='"+vehiculos.getTipo()+"'";
  PreparedStatement psquery = con.prepareStatement(sql,ResultSet.TYPE_SCROLL_INSENSITIVE,
                                      ResultSet.CONCUR_UPDATABLE);
   ResultSet rs = psquery.executeQuery();
   rs.next();
   int x = rs.getRow();
   if (x == 0) {
          excepcion=new Exception(bundle.getString("msg.nofoundrecords") + "vehiculos" +"  "+ bundle.getString("msg.withcode"));
          esMensaje =true;
      rs.close();
      psquery.close();
      return null;
   }
   rs.beforeFirst();
   while (rs.next()) {
   
        Vehiculos vehiculos2 = new Vehiculos(
         rs.getInt("idvehiculo"),rs.getString("placa"),rs.getString("marca"),rs.getString("modelo"),rs.getInt("anio"),rs.getString("chasis"),rs.getString("capacidad"),rs.getDouble("valor"),rs.getString("motor"),rs.getString("color"),rs.getString("descripcion"),rs.getString("tipo"),rs.getString("combustible"),rs.getString("uso"),rs.getString("id"),rs.getString("tipoid"),rs.getString("hipotecado"),rs.getString("secuestrado"),rs.getString("traspaso"),rs.getString("activo"),rs.getString("idmunicipio"),rs.getString("pagoinscripcion"),rs.getDate("fechainscripcion"),rs.getDate("fecha"),rs.getString("username"),rs.getString("liquidacion"),rs.getDate("fechaliquidacion"),rs.getString("mespago"),rs.getString("fideicomiso"));
            
            
       list.add(vehiculos2);
    }
    rs.close();
    psquery.close();
    return list;
} catch (Exception ex) {
      excepcion = ex;
}
  return null;
}


/**
*
* findByCombustible()
*/

public static List<Vehiculos> findByCombustible(Vehiculos vehiculos,boolean withRelation) {
  excepcion = null;
  try {
      esMensaje =false;

  con= dataGManager.getCon();
  if (con == null) {
      excepcion=new Exception(bundle.getString("msg.noconecction"));
      return null;
  }
       list = new ArrayList<Vehiculos>();
      String sql = "select * from vehiculos where combustible='"+vehiculos.getCombustible()+"'";
  PreparedStatement psquery = con.prepareStatement(sql,ResultSet.TYPE_SCROLL_INSENSITIVE,
                                      ResultSet.CONCUR_UPDATABLE);
   ResultSet rs = psquery.executeQuery();
   rs.next();
   int x = rs.getRow();
   if (x == 0) {
          excepcion=new Exception(bundle.getString("msg.nofoundrecords") + "vehiculos" +"  "+ bundle.getString("msg.withcode"));
          esMensaje =true;
      rs.close();
      psquery.close();
      return null;
   }
   rs.beforeFirst();
   while (rs.next()) {
   
        Vehiculos vehiculos2 = new Vehiculos(
         rs.getInt("idvehiculo"),rs.getString("placa"),rs.getString("marca"),rs.getString("modelo"),rs.getInt("anio"),rs.getString("chasis"),rs.getString("capacidad"),rs.getDouble("valor"),rs.getString("motor"),rs.getString("color"),rs.getString("descripcion"),rs.getString("tipo"),rs.getString("combustible"),rs.getString("uso"),rs.getString("id"),rs.getString("tipoid"),rs.getString("hipotecado"),rs.getString("secuestrado"),rs.getString("traspaso"),rs.getString("activo"),rs.getString("idmunicipio"),rs.getString("pagoinscripcion"),rs.getDate("fechainscripcion"),rs.getDate("fecha"),rs.getString("username"),rs.getString("liquidacion"),rs.getDate("fechaliquidacion"),rs.getString("mespago"),rs.getString("fideicomiso"));
            
            
       list.add(vehiculos2);
    }
    rs.close();
    psquery.close();
    return list;
} catch (Exception ex) {
      excepcion = ex;
}
  return null;
}


/**
*
* findByUso()
*/

public static List<Vehiculos> findByUso(Vehiculos vehiculos,boolean withRelation) {
  excepcion = null;
  try {
      esMensaje =false;

  con= dataGManager.getCon();
  if (con == null) {
      excepcion=new Exception(bundle.getString("msg.noconecction"));
      return null;
  }
       list = new ArrayList<Vehiculos>();
      String sql = "select * from vehiculos where uso='"+vehiculos.getUso()+"'";
  PreparedStatement psquery = con.prepareStatement(sql,ResultSet.TYPE_SCROLL_INSENSITIVE,
                                      ResultSet.CONCUR_UPDATABLE);
   ResultSet rs = psquery.executeQuery();
   rs.next();
   int x = rs.getRow();
   if (x == 0) {
          excepcion=new Exception(bundle.getString("msg.nofoundrecords") + "vehiculos" +"  "+ bundle.getString("msg.withcode"));
          esMensaje =true;
      rs.close();
      psquery.close();
      return null;
   }
   rs.beforeFirst();
   while (rs.next()) {
   
        Vehiculos vehiculos2 = new Vehiculos(
         rs.getInt("idvehiculo"),rs.getString("placa"),rs.getString("marca"),rs.getString("modelo"),rs.getInt("anio"),rs.getString("chasis"),rs.getString("capacidad"),rs.getDouble("valor"),rs.getString("motor"),rs.getString("color"),rs.getString("descripcion"),rs.getString("tipo"),rs.getString("combustible"),rs.getString("uso"),rs.getString("id"),rs.getString("tipoid"),rs.getString("hipotecado"),rs.getString("secuestrado"),rs.getString("traspaso"),rs.getString("activo"),rs.getString("idmunicipio"),rs.getString("pagoinscripcion"),rs.getDate("fechainscripcion"),rs.getDate("fecha"),rs.getString("username"),rs.getString("liquidacion"),rs.getDate("fechaliquidacion"),rs.getString("mespago"),rs.getString("fideicomiso"));
            
            
       list.add(vehiculos2);
    }
    rs.close();
    psquery.close();
    return list;
} catch (Exception ex) {
      excepcion = ex;
}
  return null;
}


/**
*
* findById()
*/

public static List<Vehiculos> findById(Vehiculos vehiculos,boolean withRelation) {
  excepcion = null;
  try {
      esMensaje =false;

  con= dataGManager.getCon();
  if (con == null) {
      excepcion=new Exception(bundle.getString("msg.noconecction"));
      return null;
  }
       list = new ArrayList<Vehiculos>();
      String sql = "select * from vehiculos where id='"+vehiculos.getId()+"'";
  PreparedStatement psquery = con.prepareStatement(sql,ResultSet.TYPE_SCROLL_INSENSITIVE,
                                      ResultSet.CONCUR_UPDATABLE);
   ResultSet rs = psquery.executeQuery();
   rs.next();
   int x = rs.getRow();
   if (x == 0) {
          excepcion=new Exception(bundle.getString("msg.nofoundrecords") + "vehiculos" +"  "+ bundle.getString("msg.withcode"));
          esMensaje =true;
      rs.close();
      psquery.close();
      return null;
   }
   rs.beforeFirst();
   while (rs.next()) {
   
        Vehiculos vehiculos2 = new Vehiculos(
         rs.getInt("idvehiculo"),rs.getString("placa"),rs.getString("marca"),rs.getString("modelo"),rs.getInt("anio"),rs.getString("chasis"),rs.getString("capacidad"),rs.getDouble("valor"),rs.getString("motor"),rs.getString("color"),rs.getString("descripcion"),rs.getString("tipo"),rs.getString("combustible"),rs.getString("uso"),rs.getString("id"),rs.getString("tipoid"),rs.getString("hipotecado"),rs.getString("secuestrado"),rs.getString("traspaso"),rs.getString("activo"),rs.getString("idmunicipio"),rs.getString("pagoinscripcion"),rs.getDate("fechainscripcion"),rs.getDate("fecha"),rs.getString("username"),rs.getString("liquidacion"),rs.getDate("fechaliquidacion"),rs.getString("mespago"),rs.getString("fideicomiso"));
            
            
       list.add(vehiculos2);
    }
    rs.close();
    psquery.close();
    return list;
} catch (Exception ex) {
      excepcion = ex;
}
  return null;
}


/**
*
* findByTipoid()
*/

public static List<Vehiculos> findByTipoid(Vehiculos vehiculos,boolean withRelation) {
  excepcion = null;
  try {
      esMensaje =false;

  con= dataGManager.getCon();
  if (con == null) {
      excepcion=new Exception(bundle.getString("msg.noconecction"));
      return null;
  }
       list = new ArrayList<Vehiculos>();
      String sql = "select * from vehiculos where tipoid='"+vehiculos.getTipoid()+"'";
  PreparedStatement psquery = con.prepareStatement(sql,ResultSet.TYPE_SCROLL_INSENSITIVE,
                                      ResultSet.CONCUR_UPDATABLE);
   ResultSet rs = psquery.executeQuery();
   rs.next();
   int x = rs.getRow();
   if (x == 0) {
          excepcion=new Exception(bundle.getString("msg.nofoundrecords") + "vehiculos" +"  "+ bundle.getString("msg.withcode"));
          esMensaje =true;
      rs.close();
      psquery.close();
      return null;
   }
   rs.beforeFirst();
   while (rs.next()) {
   
        Vehiculos vehiculos2 = new Vehiculos(
         rs.getInt("idvehiculo"),rs.getString("placa"),rs.getString("marca"),rs.getString("modelo"),rs.getInt("anio"),rs.getString("chasis"),rs.getString("capacidad"),rs.getDouble("valor"),rs.getString("motor"),rs.getString("color"),rs.getString("descripcion"),rs.getString("tipo"),rs.getString("combustible"),rs.getString("uso"),rs.getString("id"),rs.getString("tipoid"),rs.getString("hipotecado"),rs.getString("secuestrado"),rs.getString("traspaso"),rs.getString("activo"),rs.getString("idmunicipio"),rs.getString("pagoinscripcion"),rs.getDate("fechainscripcion"),rs.getDate("fecha"),rs.getString("username"),rs.getString("liquidacion"),rs.getDate("fechaliquidacion"),rs.getString("mespago"),rs.getString("fideicomiso"));
            
            
       list.add(vehiculos2);
    }
    rs.close();
    psquery.close();
    return list;
} catch (Exception ex) {
      excepcion = ex;
}
  return null;
}


/**
*
* findByHipotecado()
*/

public static List<Vehiculos> findByHipotecado(Vehiculos vehiculos,boolean withRelation) {
  excepcion = null;
  try {
      esMensaje =false;

  con= dataGManager.getCon();
  if (con == null) {
      excepcion=new Exception(bundle.getString("msg.noconecction"));
      return null;
  }
       list = new ArrayList<Vehiculos>();
      String sql = "select * from vehiculos where hipotecado='"+vehiculos.getHipotecado()+"'";
  PreparedStatement psquery = con.prepareStatement(sql,ResultSet.TYPE_SCROLL_INSENSITIVE,
                                      ResultSet.CONCUR_UPDATABLE);
   ResultSet rs = psquery.executeQuery();
   rs.next();
   int x = rs.getRow();
   if (x == 0) {
          excepcion=new Exception(bundle.getString("msg.nofoundrecords") + "vehiculos" +"  "+ bundle.getString("msg.withcode"));
          esMensaje =true;
      rs.close();
      psquery.close();
      return null;
   }
   rs.beforeFirst();
   while (rs.next()) {
   
        Vehiculos vehiculos2 = new Vehiculos(
         rs.getInt("idvehiculo"),rs.getString("placa"),rs.getString("marca"),rs.getString("modelo"),rs.getInt("anio"),rs.getString("chasis"),rs.getString("capacidad"),rs.getDouble("valor"),rs.getString("motor"),rs.getString("color"),rs.getString("descripcion"),rs.getString("tipo"),rs.getString("combustible"),rs.getString("uso"),rs.getString("id"),rs.getString("tipoid"),rs.getString("hipotecado"),rs.getString("secuestrado"),rs.getString("traspaso"),rs.getString("activo"),rs.getString("idmunicipio"),rs.getString("pagoinscripcion"),rs.getDate("fechainscripcion"),rs.getDate("fecha"),rs.getString("username"),rs.getString("liquidacion"),rs.getDate("fechaliquidacion"),rs.getString("mespago"),rs.getString("fideicomiso"));
            
            
       list.add(vehiculos2);
    }
    rs.close();
    psquery.close();
    return list;
} catch (Exception ex) {
      excepcion = ex;
}
  return null;
}


/**
*
* findBySecuestrado()
*/

public static List<Vehiculos> findBySecuestrado(Vehiculos vehiculos,boolean withRelation) {
  excepcion = null;
  try {
      esMensaje =false;

  con= dataGManager.getCon();
  if (con == null) {
      excepcion=new Exception(bundle.getString("msg.noconecction"));
      return null;
  }
       list = new ArrayList<Vehiculos>();
      String sql = "select * from vehiculos where secuestrado='"+vehiculos.getSecuestrado()+"'";
  PreparedStatement psquery = con.prepareStatement(sql,ResultSet.TYPE_SCROLL_INSENSITIVE,
                                      ResultSet.CONCUR_UPDATABLE);
   ResultSet rs = psquery.executeQuery();
   rs.next();
   int x = rs.getRow();
   if (x == 0) {
          excepcion=new Exception(bundle.getString("msg.nofoundrecords") + "vehiculos" +"  "+ bundle.getString("msg.withcode"));
          esMensaje =true;
      rs.close();
      psquery.close();
      return null;
   }
   rs.beforeFirst();
   while (rs.next()) {
   
        Vehiculos vehiculos2 = new Vehiculos(
         rs.getInt("idvehiculo"),rs.getString("placa"),rs.getString("marca"),rs.getString("modelo"),rs.getInt("anio"),rs.getString("chasis"),rs.getString("capacidad"),rs.getDouble("valor"),rs.getString("motor"),rs.getString("color"),rs.getString("descripcion"),rs.getString("tipo"),rs.getString("combustible"),rs.getString("uso"),rs.getString("id"),rs.getString("tipoid"),rs.getString("hipotecado"),rs.getString("secuestrado"),rs.getString("traspaso"),rs.getString("activo"),rs.getString("idmunicipio"),rs.getString("pagoinscripcion"),rs.getDate("fechainscripcion"),rs.getDate("fecha"),rs.getString("username"),rs.getString("liquidacion"),rs.getDate("fechaliquidacion"),rs.getString("mespago"),rs.getString("fideicomiso"));
            
            
       list.add(vehiculos2);
    }
    rs.close();
    psquery.close();
    return list;
} catch (Exception ex) {
      excepcion = ex;
}
  return null;
}


/**
*
* findByTraspaso()
*/

public static List<Vehiculos> findByTraspaso(Vehiculos vehiculos,boolean withRelation) {
  excepcion = null;
  try {
      esMensaje =false;

  con= dataGManager.getCon();
  if (con == null) {
      excepcion=new Exception(bundle.getString("msg.noconecction"));
      return null;
  }
       list = new ArrayList<Vehiculos>();
      String sql = "select * from vehiculos where traspaso='"+vehiculos.getTraspaso()+"'";
  PreparedStatement psquery = con.prepareStatement(sql,ResultSet.TYPE_SCROLL_INSENSITIVE,
                                      ResultSet.CONCUR_UPDATABLE);
   ResultSet rs = psquery.executeQuery();
   rs.next();
   int x = rs.getRow();
   if (x == 0) {
          excepcion=new Exception(bundle.getString("msg.nofoundrecords") + "vehiculos" +"  "+ bundle.getString("msg.withcode"));
          esMensaje =true;
      rs.close();
      psquery.close();
      return null;
   }
   rs.beforeFirst();
   while (rs.next()) {
   
        Vehiculos vehiculos2 = new Vehiculos(
         rs.getInt("idvehiculo"),rs.getString("placa"),rs.getString("marca"),rs.getString("modelo"),rs.getInt("anio"),rs.getString("chasis"),rs.getString("capacidad"),rs.getDouble("valor"),rs.getString("motor"),rs.getString("color"),rs.getString("descripcion"),rs.getString("tipo"),rs.getString("combustible"),rs.getString("uso"),rs.getString("id"),rs.getString("tipoid"),rs.getString("hipotecado"),rs.getString("secuestrado"),rs.getString("traspaso"),rs.getString("activo"),rs.getString("idmunicipio"),rs.getString("pagoinscripcion"),rs.getDate("fechainscripcion"),rs.getDate("fecha"),rs.getString("username"),rs.getString("liquidacion"),rs.getDate("fechaliquidacion"),rs.getString("mespago"),rs.getString("fideicomiso"));
            
            
       list.add(vehiculos2);
    }
    rs.close();
    psquery.close();
    return list;
} catch (Exception ex) {
      excepcion = ex;
}
  return null;
}


/**
*
* findByActivo()
*/

public static List<Vehiculos> findByActivo(Vehiculos vehiculos,boolean withRelation) {
  excepcion = null;
  try {
      esMensaje =false;

  con= dataGManager.getCon();
  if (con == null) {
      excepcion=new Exception(bundle.getString("msg.noconecction"));
      return null;
  }
       list = new ArrayList<Vehiculos>();
      String sql = "select * from vehiculos where activo='"+vehiculos.getActivo()+"'";
  PreparedStatement psquery = con.prepareStatement(sql,ResultSet.TYPE_SCROLL_INSENSITIVE,
                                      ResultSet.CONCUR_UPDATABLE);
   ResultSet rs = psquery.executeQuery();
   rs.next();
   int x = rs.getRow();
   if (x == 0) {
          excepcion=new Exception(bundle.getString("msg.nofoundrecords") + "vehiculos" +"  "+ bundle.getString("msg.withcode"));
          esMensaje =true;
      rs.close();
      psquery.close();
      return null;
   }
   rs.beforeFirst();
   while (rs.next()) {
   
        Vehiculos vehiculos2 = new Vehiculos(
         rs.getInt("idvehiculo"),rs.getString("placa"),rs.getString("marca"),rs.getString("modelo"),rs.getInt("anio"),rs.getString("chasis"),rs.getString("capacidad"),rs.getDouble("valor"),rs.getString("motor"),rs.getString("color"),rs.getString("descripcion"),rs.getString("tipo"),rs.getString("combustible"),rs.getString("uso"),rs.getString("id"),rs.getString("tipoid"),rs.getString("hipotecado"),rs.getString("secuestrado"),rs.getString("traspaso"),rs.getString("activo"),rs.getString("idmunicipio"),rs.getString("pagoinscripcion"),rs.getDate("fechainscripcion"),rs.getDate("fecha"),rs.getString("username"),rs.getString("liquidacion"),rs.getDate("fechaliquidacion"),rs.getString("mespago"),rs.getString("fideicomiso"));
            
            
       list.add(vehiculos2);
    }
    rs.close();
    psquery.close();
    return list;
} catch (Exception ex) {
      excepcion = ex;
}
  return null;
}


/**
*
* findByIdmunicipio()
*/

public static List<Vehiculos> findByIdmunicipio(Vehiculos vehiculos,boolean withRelation) {
  excepcion = null;
  try {
      esMensaje =false;

  con= dataGManager.getCon();
  if (con == null) {
      excepcion=new Exception(bundle.getString("msg.noconecction"));
      return null;
  }
       list = new ArrayList<Vehiculos>();
      String sql = "select * from vehiculos where idmunicipio='"+vehiculos.getIdmunicipio()+"'";
  PreparedStatement psquery = con.prepareStatement(sql,ResultSet.TYPE_SCROLL_INSENSITIVE,
                                      ResultSet.CONCUR_UPDATABLE);
   ResultSet rs = psquery.executeQuery();
   rs.next();
   int x = rs.getRow();
   if (x == 0) {
          excepcion=new Exception(bundle.getString("msg.nofoundrecords") + "vehiculos" +"  "+ bundle.getString("msg.withcode"));
          esMensaje =true;
      rs.close();
      psquery.close();
      return null;
   }
   rs.beforeFirst();
   while (rs.next()) {
   
        Vehiculos vehiculos2 = new Vehiculos(
         rs.getInt("idvehiculo"),rs.getString("placa"),rs.getString("marca"),rs.getString("modelo"),rs.getInt("anio"),rs.getString("chasis"),rs.getString("capacidad"),rs.getDouble("valor"),rs.getString("motor"),rs.getString("color"),rs.getString("descripcion"),rs.getString("tipo"),rs.getString("combustible"),rs.getString("uso"),rs.getString("id"),rs.getString("tipoid"),rs.getString("hipotecado"),rs.getString("secuestrado"),rs.getString("traspaso"),rs.getString("activo"),rs.getString("idmunicipio"),rs.getString("pagoinscripcion"),rs.getDate("fechainscripcion"),rs.getDate("fecha"),rs.getString("username"),rs.getString("liquidacion"),rs.getDate("fechaliquidacion"),rs.getString("mespago"),rs.getString("fideicomiso"));
            
            
       list.add(vehiculos2);
    }
    rs.close();
    psquery.close();
    return list;
} catch (Exception ex) {
      excepcion = ex;
}
  return null;
}


/**
*
* findByPagoinscripcion()
*/

public static List<Vehiculos> findByPagoinscripcion(Vehiculos vehiculos,boolean withRelation) {
  excepcion = null;
  try {
      esMensaje =false;

  con= dataGManager.getCon();
  if (con == null) {
      excepcion=new Exception(bundle.getString("msg.noconecction"));
      return null;
  }
       list = new ArrayList<Vehiculos>();
      String sql = "select * from vehiculos where pagoinscripcion='"+vehiculos.getPagoinscripcion()+"'";
  PreparedStatement psquery = con.prepareStatement(sql,ResultSet.TYPE_SCROLL_INSENSITIVE,
                                      ResultSet.CONCUR_UPDATABLE);
   ResultSet rs = psquery.executeQuery();
   rs.next();
   int x = rs.getRow();
   if (x == 0) {
          excepcion=new Exception(bundle.getString("msg.nofoundrecords") + "vehiculos" +"  "+ bundle.getString("msg.withcode"));
          esMensaje =true;
      rs.close();
      psquery.close();
      return null;
   }
   rs.beforeFirst();
   while (rs.next()) {
   
        Vehiculos vehiculos2 = new Vehiculos(
         rs.getInt("idvehiculo"),rs.getString("placa"),rs.getString("marca"),rs.getString("modelo"),rs.getInt("anio"),rs.getString("chasis"),rs.getString("capacidad"),rs.getDouble("valor"),rs.getString("motor"),rs.getString("color"),rs.getString("descripcion"),rs.getString("tipo"),rs.getString("combustible"),rs.getString("uso"),rs.getString("id"),rs.getString("tipoid"),rs.getString("hipotecado"),rs.getString("secuestrado"),rs.getString("traspaso"),rs.getString("activo"),rs.getString("idmunicipio"),rs.getString("pagoinscripcion"),rs.getDate("fechainscripcion"),rs.getDate("fecha"),rs.getString("username"),rs.getString("liquidacion"),rs.getDate("fechaliquidacion"),rs.getString("mespago"),rs.getString("fideicomiso"));
            
            
       list.add(vehiculos2);
    }
    rs.close();
    psquery.close();
    return list;
} catch (Exception ex) {
      excepcion = ex;
}
  return null;
}


/**
*
* findByFechainscripcion()
*/

public static List<Vehiculos> findByFechainscripcion(Vehiculos vehiculos,boolean withRelation) {
  excepcion = null;
  try {
      esMensaje =false;

  con= dataGManager.getCon();
  if (con == null) {
      excepcion=new Exception(bundle.getString("msg.noconecction"));
      return null;
  }
       list = new ArrayList<Vehiculos>();
      String sql = "select * from vehiculos where fechainscripcion='"+vehiculos.getFechainscripcion()+"'";
  PreparedStatement psquery = con.prepareStatement(sql,ResultSet.TYPE_SCROLL_INSENSITIVE,
                                      ResultSet.CONCUR_UPDATABLE);
   ResultSet rs = psquery.executeQuery();
   rs.next();
   int x = rs.getRow();
   if (x == 0) {
          excepcion=new Exception(bundle.getString("msg.nofoundrecords") + "vehiculos" +"  "+ bundle.getString("msg.withcode"));
          esMensaje =true;
      rs.close();
      psquery.close();
      return null;
   }
   rs.beforeFirst();
   while (rs.next()) {
   
        Vehiculos vehiculos2 = new Vehiculos(
         rs.getInt("idvehiculo"),rs.getString("placa"),rs.getString("marca"),rs.getString("modelo"),rs.getInt("anio"),rs.getString("chasis"),rs.getString("capacidad"),rs.getDouble("valor"),rs.getString("motor"),rs.getString("color"),rs.getString("descripcion"),rs.getString("tipo"),rs.getString("combustible"),rs.getString("uso"),rs.getString("id"),rs.getString("tipoid"),rs.getString("hipotecado"),rs.getString("secuestrado"),rs.getString("traspaso"),rs.getString("activo"),rs.getString("idmunicipio"),rs.getString("pagoinscripcion"),rs.getDate("fechainscripcion"),rs.getDate("fecha"),rs.getString("username"),rs.getString("liquidacion"),rs.getDate("fechaliquidacion"),rs.getString("mespago"),rs.getString("fideicomiso"));
            
            
       list.add(vehiculos2);
    }
    rs.close();
    psquery.close();
    return list;
} catch (Exception ex) {
      excepcion = ex;
}
  return null;
}


/**
*
* findByFecha()
*/

public static List<Vehiculos> findByFecha(Vehiculos vehiculos,boolean withRelation) {
  excepcion = null;
  try {
      esMensaje =false;

  con= dataGManager.getCon();
  if (con == null) {
      excepcion=new Exception(bundle.getString("msg.noconecction"));
      return null;
  }
       list = new ArrayList<Vehiculos>();
      String sql = "select * from vehiculos where fecha='"+vehiculos.getFecha()+"'";
  PreparedStatement psquery = con.prepareStatement(sql,ResultSet.TYPE_SCROLL_INSENSITIVE,
                                      ResultSet.CONCUR_UPDATABLE);
   ResultSet rs = psquery.executeQuery();
   rs.next();
   int x = rs.getRow();
   if (x == 0) {
          excepcion=new Exception(bundle.getString("msg.nofoundrecords") + "vehiculos" +"  "+ bundle.getString("msg.withcode"));
          esMensaje =true;
      rs.close();
      psquery.close();
      return null;
   }
   rs.beforeFirst();
   while (rs.next()) {
   
        Vehiculos vehiculos2 = new Vehiculos(
         rs.getInt("idvehiculo"),rs.getString("placa"),rs.getString("marca"),rs.getString("modelo"),rs.getInt("anio"),rs.getString("chasis"),rs.getString("capacidad"),rs.getDouble("valor"),rs.getString("motor"),rs.getString("color"),rs.getString("descripcion"),rs.getString("tipo"),rs.getString("combustible"),rs.getString("uso"),rs.getString("id"),rs.getString("tipoid"),rs.getString("hipotecado"),rs.getString("secuestrado"),rs.getString("traspaso"),rs.getString("activo"),rs.getString("idmunicipio"),rs.getString("pagoinscripcion"),rs.getDate("fechainscripcion"),rs.getDate("fecha"),rs.getString("username"),rs.getString("liquidacion"),rs.getDate("fechaliquidacion"),rs.getString("mespago"),rs.getString("fideicomiso"));
            
            
       list.add(vehiculos2);
    }
    rs.close();
    psquery.close();
    return list;
} catch (Exception ex) {
      excepcion = ex;
}
  return null;
}


/**
*
* findByUsername()
*/

public static List<Vehiculos> findByUsername(Vehiculos vehiculos,boolean withRelation) {
  excepcion = null;
  try {
      esMensaje =false;

  con= dataGManager.getCon();
  if (con == null) {
      excepcion=new Exception(bundle.getString("msg.noconecction"));
      return null;
  }
       list = new ArrayList<Vehiculos>();
      String sql = "select * from vehiculos where username='"+vehiculos.getUsername()+"'";
  PreparedStatement psquery = con.prepareStatement(sql,ResultSet.TYPE_SCROLL_INSENSITIVE,
                                      ResultSet.CONCUR_UPDATABLE);
   ResultSet rs = psquery.executeQuery();
   rs.next();
   int x = rs.getRow();
   if (x == 0) {
          excepcion=new Exception(bundle.getString("msg.nofoundrecords") + "vehiculos" +"  "+ bundle.getString("msg.withcode"));
          esMensaje =true;
      rs.close();
      psquery.close();
      return null;
   }
   rs.beforeFirst();
   while (rs.next()) {
   
        Vehiculos vehiculos2 = new Vehiculos(
         rs.getInt("idvehiculo"),rs.getString("placa"),rs.getString("marca"),rs.getString("modelo"),rs.getInt("anio"),rs.getString("chasis"),rs.getString("capacidad"),rs.getDouble("valor"),rs.getString("motor"),rs.getString("color"),rs.getString("descripcion"),rs.getString("tipo"),rs.getString("combustible"),rs.getString("uso"),rs.getString("id"),rs.getString("tipoid"),rs.getString("hipotecado"),rs.getString("secuestrado"),rs.getString("traspaso"),rs.getString("activo"),rs.getString("idmunicipio"),rs.getString("pagoinscripcion"),rs.getDate("fechainscripcion"),rs.getDate("fecha"),rs.getString("username"),rs.getString("liquidacion"),rs.getDate("fechaliquidacion"),rs.getString("mespago"),rs.getString("fideicomiso"));
            
            
       list.add(vehiculos2);
    }
    rs.close();
    psquery.close();
    return list;
} catch (Exception ex) {
      excepcion = ex;
}
  return null;
}


/**
*
* findByLiquidacion()
*/

public static List<Vehiculos> findByLiquidacion(Vehiculos vehiculos,boolean withRelation) {
  excepcion = null;
  try {
      esMensaje =false;

  con= dataGManager.getCon();
  if (con == null) {
      excepcion=new Exception(bundle.getString("msg.noconecction"));
      return null;
  }
       list = new ArrayList<Vehiculos>();
      String sql = "select * from vehiculos where liquidacion='"+vehiculos.getLiquidacion()+"'";
  PreparedStatement psquery = con.prepareStatement(sql,ResultSet.TYPE_SCROLL_INSENSITIVE,
                                      ResultSet.CONCUR_UPDATABLE);
   ResultSet rs = psquery.executeQuery();
   rs.next();
   int x = rs.getRow();
   if (x == 0) {
          excepcion=new Exception(bundle.getString("msg.nofoundrecords") + "vehiculos" +"  "+ bundle.getString("msg.withcode"));
          esMensaje =true;
      rs.close();
      psquery.close();
      return null;
   }
   rs.beforeFirst();
   while (rs.next()) {
   
        Vehiculos vehiculos2 = new Vehiculos(
         rs.getInt("idvehiculo"),rs.getString("placa"),rs.getString("marca"),rs.getString("modelo"),rs.getInt("anio"),rs.getString("chasis"),rs.getString("capacidad"),rs.getDouble("valor"),rs.getString("motor"),rs.getString("color"),rs.getString("descripcion"),rs.getString("tipo"),rs.getString("combustible"),rs.getString("uso"),rs.getString("id"),rs.getString("tipoid"),rs.getString("hipotecado"),rs.getString("secuestrado"),rs.getString("traspaso"),rs.getString("activo"),rs.getString("idmunicipio"),rs.getString("pagoinscripcion"),rs.getDate("fechainscripcion"),rs.getDate("fecha"),rs.getString("username"),rs.getString("liquidacion"),rs.getDate("fechaliquidacion"),rs.getString("mespago"),rs.getString("fideicomiso"));
            
            
       list.add(vehiculos2);
    }
    rs.close();
    psquery.close();
    return list;
} catch (Exception ex) {
      excepcion = ex;
}
  return null;
}


/**
*
* findByFechaliquidacion()
*/

public static List<Vehiculos> findByFechaliquidacion(Vehiculos vehiculos,boolean withRelation) {
  excepcion = null;
  try {
      esMensaje =false;

  con= dataGManager.getCon();
  if (con == null) {
      excepcion=new Exception(bundle.getString("msg.noconecction"));
      return null;
  }
       list = new ArrayList<Vehiculos>();
      String sql = "select * from vehiculos where fechaliquidacion='"+vehiculos.getFechaliquidacion()+"'";
  PreparedStatement psquery = con.prepareStatement(sql,ResultSet.TYPE_SCROLL_INSENSITIVE,
                                      ResultSet.CONCUR_UPDATABLE);
   ResultSet rs = psquery.executeQuery();
   rs.next();
   int x = rs.getRow();
   if (x == 0) {
          excepcion=new Exception(bundle.getString("msg.nofoundrecords") + "vehiculos" +"  "+ bundle.getString("msg.withcode"));
          esMensaje =true;
      rs.close();
      psquery.close();
      return null;
   }
   rs.beforeFirst();
   while (rs.next()) {
   
        Vehiculos vehiculos2 = new Vehiculos(
         rs.getInt("idvehiculo"),rs.getString("placa"),rs.getString("marca"),rs.getString("modelo"),rs.getInt("anio"),rs.getString("chasis"),rs.getString("capacidad"),rs.getDouble("valor"),rs.getString("motor"),rs.getString("color"),rs.getString("descripcion"),rs.getString("tipo"),rs.getString("combustible"),rs.getString("uso"),rs.getString("id"),rs.getString("tipoid"),rs.getString("hipotecado"),rs.getString("secuestrado"),rs.getString("traspaso"),rs.getString("activo"),rs.getString("idmunicipio"),rs.getString("pagoinscripcion"),rs.getDate("fechainscripcion"),rs.getDate("fecha"),rs.getString("username"),rs.getString("liquidacion"),rs.getDate("fechaliquidacion"),rs.getString("mespago"),rs.getString("fideicomiso"));
            
            
       list.add(vehiculos2);
    }
    rs.close();
    psquery.close();
    return list;
} catch (Exception ex) {
      excepcion = ex;
}
  return null;
}


/**
*
* findByMespago()
*/

public static List<Vehiculos> findByMespago(Vehiculos vehiculos,boolean withRelation) {
  excepcion = null;
  try {
      esMensaje =false;

  con= dataGManager.getCon();
  if (con == null) {
      excepcion=new Exception(bundle.getString("msg.noconecction"));
      return null;
  }
       list = new ArrayList<Vehiculos>();
      String sql = "select * from vehiculos where mespago='"+vehiculos.getMespago()+"'";
  PreparedStatement psquery = con.prepareStatement(sql,ResultSet.TYPE_SCROLL_INSENSITIVE,
                                      ResultSet.CONCUR_UPDATABLE);
   ResultSet rs = psquery.executeQuery();
   rs.next();
   int x = rs.getRow();
   if (x == 0) {
          excepcion=new Exception(bundle.getString("msg.nofoundrecords") + "vehiculos" +"  "+ bundle.getString("msg.withcode"));
          esMensaje =true;
      rs.close();
      psquery.close();
      return null;
   }
   rs.beforeFirst();
   while (rs.next()) {
   
        Vehiculos vehiculos2 = new Vehiculos(
         rs.getInt("idvehiculo"),rs.getString("placa"),rs.getString("marca"),rs.getString("modelo"),rs.getInt("anio"),rs.getString("chasis"),rs.getString("capacidad"),rs.getDouble("valor"),rs.getString("motor"),rs.getString("color"),rs.getString("descripcion"),rs.getString("tipo"),rs.getString("combustible"),rs.getString("uso"),rs.getString("id"),rs.getString("tipoid"),rs.getString("hipotecado"),rs.getString("secuestrado"),rs.getString("traspaso"),rs.getString("activo"),rs.getString("idmunicipio"),rs.getString("pagoinscripcion"),rs.getDate("fechainscripcion"),rs.getDate("fecha"),rs.getString("username"),rs.getString("liquidacion"),rs.getDate("fechaliquidacion"),rs.getString("mespago"),rs.getString("fideicomiso"));
            
            
       list.add(vehiculos2);
    }
    rs.close();
    psquery.close();
    return list;
} catch (Exception ex) {
      excepcion = ex;
}
  return null;
}


/**
*
* findByFideicomiso()
*/

public static List<Vehiculos> findByFideicomiso(Vehiculos vehiculos,boolean withRelation) {
  excepcion = null;
  try {
      esMensaje =false;

  con= dataGManager.getCon();
  if (con == null) {
      excepcion=new Exception(bundle.getString("msg.noconecction"));
      return null;
  }
       list = new ArrayList<Vehiculos>();
      String sql = "select * from vehiculos where fideicomiso='"+vehiculos.getFideicomiso()+"'";
  PreparedStatement psquery = con.prepareStatement(sql,ResultSet.TYPE_SCROLL_INSENSITIVE,
                                      ResultSet.CONCUR_UPDATABLE);
   ResultSet rs = psquery.executeQuery();
   rs.next();
   int x = rs.getRow();
   if (x == 0) {
          excepcion=new Exception(bundle.getString("msg.nofoundrecords") + "vehiculos" +"  "+ bundle.getString("msg.withcode"));
          esMensaje =true;
      rs.close();
      psquery.close();
      return null;
   }
   rs.beforeFirst();
   while (rs.next()) {
   
        Vehiculos vehiculos2 = new Vehiculos(
         rs.getInt("idvehiculo"),rs.getString("placa"),rs.getString("marca"),rs.getString("modelo"),rs.getInt("anio"),rs.getString("chasis"),rs.getString("capacidad"),rs.getDouble("valor"),rs.getString("motor"),rs.getString("color"),rs.getString("descripcion"),rs.getString("tipo"),rs.getString("combustible"),rs.getString("uso"),rs.getString("id"),rs.getString("tipoid"),rs.getString("hipotecado"),rs.getString("secuestrado"),rs.getString("traspaso"),rs.getString("activo"),rs.getString("idmunicipio"),rs.getString("pagoinscripcion"),rs.getDate("fechainscripcion"),rs.getDate("fecha"),rs.getString("username"),rs.getString("liquidacion"),rs.getDate("fechaliquidacion"),rs.getString("mespago"),rs.getString("fideicomiso"));
            
            
       list.add(vehiculos2);
    }
    rs.close();
    psquery.close();
    return list;
} catch (Exception ex) {
      excepcion = ex;
}
  return null;
}


/**
*
* locateByParameters()
*/

public static List<Vehiculos> locateByParameters(Map parametros,boolean withRelation) {
  excepcion = null;
  try {
      esMensaje =false;

  con= dataGManager.getCon();
  if (con == null) {
      excepcion=new Exception(bundle.getString("msg.noconecction"));
      return null;
  }
       list = new ArrayList<Vehiculos>();
  String sql = "select * from vehiculos";
  if (parametros != null) {
      Iterator it = parametros.entrySet().iterator();
      StringBuilder sb = new StringBuilder("");
      int i = 0;
      while (it.hasNext()) {
          if (i != 0){
            sb.append(" and ");
         }
         i++;
        Map.Entry e = (Map.Entry) it.next();
        sb.append(e.getKey() +"= '"+  e.getValue()+"'");
      }
      if (!sb.toString().equals("")){
         sql = sql + " where " + sb.toString();
      }
   }
  PreparedStatement psquery = con.prepareStatement(sql,ResultSet.TYPE_SCROLL_INSENSITIVE,
                                      ResultSet.CONCUR_UPDATABLE);
   ResultSet rs = psquery.executeQuery();
   rs.next();
   int x = rs.getRow();
   if (x == 0) {
          excepcion=new Exception(bundle.getString("msg.nofoundrecords") + "vehiculos" +"  "+ bundle.getString("msg.withcode"));
          esMensaje =true;
      rs.close();
      psquery.close();
      return null;
   }
   rs.beforeFirst();
   while (rs.next()) {
   
        Vehiculos vehiculos2 = new Vehiculos(
         rs.getInt("idvehiculo"),rs.getString("placa"),rs.getString("marca"),rs.getString("modelo"),rs.getInt("anio"),rs.getString("chasis"),rs.getString("capacidad"),rs.getDouble("valor"),rs.getString("motor"),rs.getString("color"),rs.getString("descripcion"),rs.getString("tipo"),rs.getString("combustible"),rs.getString("uso"),rs.getString("id"),rs.getString("tipoid"),rs.getString("hipotecado"),rs.getString("secuestrado"),rs.getString("traspaso"),rs.getString("activo"),rs.getString("idmunicipio"),rs.getString("pagoinscripcion"),rs.getDate("fechainscripcion"),rs.getDate("fecha"),rs.getString("username"),rs.getString("liquidacion"),rs.getDate("fechaliquidacion"),rs.getString("mespago"),rs.getString("fideicomiso"));
            
            
       list.add(vehiculos2);
    }
    rs.close();
    psquery.close();
    return list;
} catch (Exception ex) {
      excepcion = ex;
}
  return null;
}


/**
*
* Double fFunc(String funcion, String campo)
*/



public static Double func(String funcion, String campo) {
  excepcion = null;
  try {
      esMensaje =false;

  con= dataGManager.getCon();
  if (con == null) {
      excepcion=new Exception(bundle.getString("msg.noconecction"));
      return 0.0;
  }
      String sql = "select "+funcion+"("+campo+") as contador from vehiculos";
  PreparedStatement psquery = con.prepareStatement(sql,ResultSet.TYPE_SCROLL_INSENSITIVE,
                                      ResultSet.CONCUR_UPDATABLE);
   ResultSet rs = psquery.executeQuery();
   rs.next();
   int x = rs.getRow();
   if (x == 0) {
          excepcion=new Exception(bundle.getString("msg.nofoundrecords") + "vehiculos" +"  "+ bundle.getString("msg.withcode"));
          esMensaje =true;
      rs.close();
      psquery.close();
      return 0.0;
   }
    Double tmp =0.0;
   rs.beforeFirst();
   while (rs.next()) {
    tmp =  rs.getDouble("contador");
    }
    rs.close();
    psquery.close();
 return tmp;
} catch (Exception ex) {
      excepcion = ex;
}
  return 0.0;
}


/**
*
* Double func(String funcion, String campo,String where)
*/



public static Double func(String funcion, String campo, String where) {
  excepcion = null;
  try {
      esMensaje =false;

  con= dataGManager.getCon();
  if (con == null) {
      excepcion=new Exception(bundle.getString("msg.noconecction"));
      return 0.0;
  }
      String sql = "select "+funcion+"("+campo+") as contador from vehiculos where "+where +" ";
  PreparedStatement psquery = con.prepareStatement(sql,ResultSet.TYPE_SCROLL_INSENSITIVE,
                                      ResultSet.CONCUR_UPDATABLE);
   ResultSet rs = psquery.executeQuery();
   rs.next();
   int x = rs.getRow();
   if (x == 0) {
          excepcion=new Exception(bundle.getString("msg.nofoundrecords") + "vehiculos" +"  "+ bundle.getString("msg.withcode"));
          esMensaje =true;
      rs.close();
      psquery.close();
      return 0.0;
   }
    Double tmp =0.0;
   rs.beforeFirst();
   while (rs.next()) {
    tmp =  rs.getDouble("contador");
    }
    rs.close();
    psquery.close();
 return tmp;
} catch (Exception ex) {
      excepcion = ex;
}
  return 0.0;
}


/**
*
* count()
*/



public static Integer count() {
  excepcion = null;
  try {
      esMensaje =false;

  con= dataGManager.getCon();
  if (con == null) {
      excepcion=new Exception(bundle.getString("msg.noconecction"));
      return 0;
  }
      String sql = "select count(*) as contador from vehiculos";
  PreparedStatement psquery = con.prepareStatement(sql,ResultSet.TYPE_SCROLL_INSENSITIVE,
                                      ResultSet.CONCUR_UPDATABLE);
   ResultSet rs = psquery.executeQuery();
   rs.next();
   int x = rs.getRow();
   if (x == 0) {
          excepcion=new Exception(bundle.getString("msg.nofoundrecords") + "vehiculos" +"  "+ bundle.getString("msg.withcode"));
          esMensaje =true;
      rs.close();
      psquery.close();
      return 0;
   }
   rs.beforeFirst();
   while (rs.next()) {
    x =  rs.getInt("contador");
    }
    rs.close();
    psquery.close();
 return x;
} catch (Exception ex) {
      excepcion = ex;
}
  return 0;
}


/**
*
* count(String sqlquery)
*/



public static Integer count(String sqlquery) {
  excepcion = null;
  try {
      esMensaje =false;

  con= dataGManager.getCon();
  if (con == null) {
      excepcion=new Exception(bundle.getString("msg.noconecction"));
      return 0;
  }
      String sql = "select count(*) as contador from vehiculos where  " + sqlquery +"";
  PreparedStatement psquery = con.prepareStatement(sql,ResultSet.TYPE_SCROLL_INSENSITIVE,
                                      ResultSet.CONCUR_UPDATABLE);
   ResultSet rs = psquery.executeQuery();
   rs.next();
   int x = rs.getRow();
   if (x == 0) {
          excepcion=new Exception(bundle.getString("msg.nofoundrecords") + "vehiculos" +"  "+ bundle.getString("msg.withcode"));
          esMensaje =true;
      rs.close();
      psquery.close();
      return 0;
   }
   rs.beforeFirst();
   while (rs.next()) {
    x =  rs.getInt("contador");
    }
    rs.close();
    psquery.close();
 return x;
} catch (Exception ex) {
      excepcion = ex;
}
  return 0;
}


/**
*
* query()
*/

public static List<Vehiculos> query(String query,boolean withRelation) {
  excepcion = null;
  try {
      esMensaje =false;

  con= dataGManager.getCon();
  if (con == null) {
      excepcion=new Exception(bundle.getString("msg.noconecction"));
      return null;
  }
        list = new ArrayList<Vehiculos>();
  String sql = "select * from vehiculos where " + query +"";
  if (query == null || query.equals("")) {
  return null;
   }
  PreparedStatement psquery = con.prepareStatement(sql,ResultSet.TYPE_SCROLL_INSENSITIVE,
                                      ResultSet.CONCUR_UPDATABLE);
   ResultSet rs = psquery.executeQuery();
   rs.next();
   int x = rs.getRow();
   if (x == 0) {
          excepcion=new Exception(bundle.getString("msg.nofoundrecords") + "vehiculos" +"  "+ bundle.getString("msg.withcode"));
          esMensaje =true;
      rs.close();
      psquery.close();
      return null;
   }
   rs.beforeFirst();
   while (rs.next()) {
   
        Vehiculos vehiculos2 = new Vehiculos(
         rs.getInt("idvehiculo"),rs.getString("placa"),rs.getString("marca"),rs.getString("modelo"),rs.getInt("anio"),rs.getString("chasis"),rs.getString("capacidad"),rs.getDouble("valor"),rs.getString("motor"),rs.getString("color"),rs.getString("descripcion"),rs.getString("tipo"),rs.getString("combustible"),rs.getString("uso"),rs.getString("id"),rs.getString("tipoid"),rs.getString("hipotecado"),rs.getString("secuestrado"),rs.getString("traspaso"),rs.getString("activo"),rs.getString("idmunicipio"),rs.getString("pagoinscripcion"),rs.getDate("fechainscripcion"),rs.getDate("fecha"),rs.getString("username"),rs.getString("liquidacion"),rs.getDate("fechaliquidacion"),rs.getString("mespago"),rs.getString("fideicomiso"));
            
            
       list.add(vehiculos2);
    }
    rs.close();
    psquery.close();
    return list;
} catch (Exception ex) {
      excepcion = ex;
}
  return null;
}


/**
*
* getListRecords()
*/

public static List<Vehiculos> getListRecords(Map parametros,boolean withRelation) {
  excepcion = null;
  try {
      esMensaje =false;

  con= dataGManager.getCon();
  if (con == null) {
      excepcion=new Exception(bundle.getString("msg.noconecction"));
      return null;
  }
      list = new ArrayList<Vehiculos>();
  String sql = "select * from vehiculos";
  if (parametros != null) {
      Iterator it = parametros.entrySet().iterator();
      StringBuilder sb = new StringBuilder("");
      while (it.hasNext()) {
        Map.Entry e = (Map.Entry) it.next();
        sb.append(e.getKey() +"="+  e.getValue());
      }
      if (!sb.toString().equals("")){
         sql = sql + " where " + sb.toString();
      }
   }
  PreparedStatement psquery = con.prepareStatement(sql,ResultSet.TYPE_SCROLL_INSENSITIVE,
                                      ResultSet.CONCUR_UPDATABLE);
   ResultSet rs = psquery.executeQuery();
   rs.next();
   int x = rs.getRow();
   if (x == 0) {
          excepcion=new Exception(bundle.getString("msg.nofoundrecords") + "vehiculos" +"  "+ bundle.getString("msg.withcode"));
          esMensaje =true;
      rs.close();
      psquery.close();
      return null;
   }
   rs.beforeFirst();
   while (rs.next()) {
       
        Vehiculos vehiculos2 = new Vehiculos(
         rs.getInt("idvehiculo"),rs.getString("placa"),rs.getString("marca"),rs.getString("modelo"),rs.getInt("anio"),rs.getString("chasis"),rs.getString("capacidad"),rs.getDouble("valor"),rs.getString("motor"),rs.getString("color"),rs.getString("descripcion"),rs.getString("tipo"),rs.getString("combustible"),rs.getString("uso"),rs.getString("id"),rs.getString("tipoid"),rs.getString("hipotecado"),rs.getString("secuestrado"),rs.getString("traspaso"),rs.getString("activo"),rs.getString("idmunicipio"),rs.getString("pagoinscripcion"),rs.getDate("fechainscripcion"),rs.getDate("fecha"),rs.getString("username"),rs.getString("liquidacion"),rs.getDate("fechaliquidacion"),rs.getString("mespago"),rs.getString("fideicomiso"));
            
            
       list.add(vehiculos2);
    }
    rs.close();
    psquery.close();
    return list;
} catch (Exception ex) {
      excepcion = ex;
}
  return null;
 }


}
